<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
   Modifications to cpd.xsl original Copyright (c) 2009 Fred Grott
   ASfv2 license where appplicable.
-->
<!DOCTYPE pd [
  <!-- ====================================================================
       Mapping of images onto files
       ==================================================================== -->
  <!ENTITY logoImg            "images/pmd_logo_small.jpg">
  <!ENTITY companylogoImg     "images/companylogo.png">
  <!ENTITY linkImg            "images/link.png">
  <!ENTITY mixedCycleLinkImg       "images/mixedCycleLink.png">
  <!ENTITY innerCycleLinkImg       "images/innerCycleLink.png">
  <!ENTITY mixImg             "images/mix.png">
  <!ENTITY packageImg         "images/package.png">
  <!ENTITY innerImg           "images/inner.png">
  <!ENTITY classImg           "images/class.png">
  <!ENTITY abstractImg        "images/abstract.png">
  <!ENTITY interfaceImg       "images/interface.png">
  <!ENTITY innerclassImg      "images/innerclass.png">
  <!ENTITY innerabstractImg   "images/innerabstract.png">
  <!ENTITY innerinterfaceImg  "images/innerinterface.png">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" 
     indent="yes"  />
<xsl:param name="project" select="files"/>
<xsl:param name="today" select="today"/>
<xsl:param name="context-root" select="context-root"/>
<xsl:param name="source-root" select="source-root"/>

  <xsl:template match="/pmd-cpd">
    <html>
    <head>
    <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"/>
    <title>CPD Analysis of <xsl:value-of select="$project"/> source code</title>
    <link rel="stylesheet" type="text/css" href="andcooper.reports.css"/>
    </head>
    <body>
    <h1><img src="&companylogoImg;"/></h1>
    <h1><img src="&logoImg;"/>Copy/Paste Detector (CPD) Analysis of <xsl:value-of select="$project"/> source code</h1>
    <p align="right">Run with <a href="http://pmd.sourceforge.net">CPD</a> on <xsl:value-of select="$today"/></p>
    <hr size="2"/>
    <table class="summary">
        <tr>
            <th>Duplications Found</th>
        </tr>
        <tr>
            <td><xsl:value-of select="count(//duplication)" /></td>
        </tr>
    </table>
    <hr size="2" />
    <xsl:apply-templates/>

    </body>
    </html>
  </xsl:template>

  <xsl:template match="//duplication">
    <xsl:variable name="filename" select="@name"/>
    <table class="details">
    <tr>
    <th>
    Found a <xsl:value-of select="@lines"/> line duplication in the following files
    </th>
    </tr>
    <xsl:apply-templates/>
    </table>
    <p/>
  </xsl:template>

  <xsl:template match="file">
   <xsl:variable name="path" select="@path"/>
   <xsl:variable name="line" select="@line"/>
   <xsl:variable name="translated-path" select="translate(@path, '\', '/')"/>
   <xsl:variable name="translated-source-root" select="translate($source-root, '\', '/')"/>
   <xsl:variable name="linkpath" select="substring-after($translated-path, $translated-source-root)"/>
   <xsl:variable name="class-name" select="translate($linkpath, '/', '.')"/>
   <tr>
   <td class="file">Starting at <a href="{$context-root}/{$linkpath}.html#{$line}">line <xsl:value-of select="@line"/></a> of <xsl:value-of select="$class-name"/></td>
   </tr>
  </xsl:template>

  <xsl:template match="codefragment">
    <tr>
    <td><pre><xsl:value-of select="."/></pre></td>
    </tr>
  </xsl:template>

</xsl:stylesheet>
